
package com.ukao.steward.pesenter.logistics;

import com.ukao.steward.base.BasePresenter;
import com.ukao.steward.bean.EnterFactoryBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.consts.SaveParams;
import com.ukao.steward.retrofit.ApiCallback;
import com.ukao.steward.view.logistics.EnterFactoryView;

import java.util.HashMap;


import rx.Observable;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class EnterFactoryPesenter extends BasePresenter<EnterFactoryView> {
    private boolean isloaderr;

    public EnterFactoryPesenter(EnterFactoryView view) {
        attachView(view);
    }

    /**
     *入厂 未取
     */
    public void enterFactoryNotTake(  int pageNum ,int pageSize,int  type) {

        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("pageNum",pageNum+"");
        mHashMap.put("pageSize",pageSize+"");
        mHashMap.put("accessToken", SaveParams.getToken());
        Observable observable = null;
        switch (type) {   /*未送厂*/
            case 1:
                observable=apiStores.sendFactoryNotTake(Constant.createParameter(mHashMap));

                break;
            case 2:   /*已到厂*/
                observable=apiStores.arriveFactoryN(Constant.createParameter(mHashMap));

                break;

            case  3:  /*进厂订单（未送厂）*/

                observable=apiStores.sendingList(Constant.createParameter(mHashMap));
                break;

            case  4:  /*进厂订单 - 已到厂*/
                observable=apiStores.reachFactoryIn(Constant.createParameter(mHashMap));
                break;
        }


        addSubscription(observable,
                new ApiCallback<EnterFactoryBean>() {
                    @Override
                    public void onSuccess(EnterFactoryBean model) {

                        if (model.getHttpCode() == 200) {

                            mvpView.enterFactorySucceed(model.getData());
                        }else{

                              mvpView.showError(model.getMsg());
                        }

                    }


                    @Override
                    public void onFinish() {

                    mvpView.loadfinish();

                    }
                });
    }








}
